/*
 * @(#)XfplotColorIcon.java        2003/01/01
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */


package xfuzzy.xfplot.view;

import xfuzzy.xfplot.model.*;
import javax.swing.*;
import java.awt.*;

/**
 * Icono para representar el modelo de color
 * 
 * @author Francisco Jos� Moreno Velo
 *
 */
public class XfplotColorIcon implements Icon {
	
	//----------------------------------------------------------------------------//
	//                            MIEMBROS PRIVADOS                              //
	//----------------------------------------------------------------------------//
	
	/**
	 * Objeto que desarrolla el modelo de colores
	 */
	private XfplotColorModel model;
	
	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//
	
	/**
	 * Constructor
	 */
	public XfplotColorIcon(int colormodel) {
		this.model = new XfplotColorModel(colormodel);
	}
	
 	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//
	
	/**
	 * Dibuja el icono
	 */
	public void paintIcon(Component c, Graphics g, int x, int y) {
		Color old_c = g.getColor();
		for(int i=0; i<=10; i++) {
			g.setColor(model.getColor(0.1*i));
			g.fillRect(x+12*i,y,12,12);
		}   
		Color grid = model.getGridColor();
		if(grid != null) {
			g.setColor(grid);
			for(int i=0; i<=10; i++) g.drawRect(x+12*i,y,12,12);
		}
		g.setColor(old_c);
	}
	
	/**
	 * Anchura del icono
	 */
	public int getIconWidth() {
		return 154;
	}
	
	/**
	 * Altura del icono
	 */
	public int getIconHeight() {
		return 14;
	}
}
